package com.haibara.codesandbox.schedule;

import com.haibara.codesandbox.pool.containerPool.ContainerPool;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;


/**
 * 清理容器任务
 *
 * @Author: mengyu
 * @Date: 2025/6/22
 */
@Slf4j
@Component
public class ContainerCleanupSchedule {

    private final ContainerPool containerPool;

    public ContainerCleanupSchedule(ContainerPool containerPool) {
        this.containerPool = containerPool;
    }

    @Scheduled(cron = "0 0 0 * * ?")
    public void dailyContainerCleanup() {
        log.info("开始执行每日容器清理任务");
        containerPool.clearAllContainer();
        log.info("容器清理任务执行完成");
    }
}